package com.tm.controller;

import com.tm.entity.OrderEntiy;
import com.tm.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping
public class OrderController {

    @Autowired
    private OrderService orderService;
    @PostMapping("createOrder")
    public int createOrder(@RequestBody  Map<String,String> map){
        OrderEntiy orderEntiy = new OrderEntiy();
        orderEntiy.setUserId(Long.parseLong(map.get("userId")));
        orderEntiy.setProductId(Long.parseLong(map.get("productId")));
        orderEntiy.setMoney(Integer.parseInt(map.get("money")+""));
       return orderService.createOrder(orderEntiy);
    }
}
